import datetime
from dateutil.relativedelta import relativedelta

def calc_date(date, n):
    if type(date) in (int, str):
        dt = datetime.datetime.strptime(int(date),'%Y%m%d')
    else:
        dt = date
    return dt-relativedelta(days=n)
